﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ScrumDashboard.Library.Tfs;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace ScrumDashboardMvc.Controllers
{
    public class Anchor
    {
        public string Text { get; set; }
        public string Href { get; set; }

        public override string ToString()
        {
             return "<a href='" + Href + "'>" + Text + "</a>";
        }
    }

    //public class ApiTestController : Controller
    //{
    //    //
    //    // GET: /ApiTest/

    //    public ActionResult Index()
    //    {
    //        return View(GetType().GetMethods().Where(m => typeof(ActionResult).IsAssignableFrom(m.ReturnType))
    //            .Select(m => new Anchor { Text = m.Name, Href = RouteData.Values["controller"] + "/" + m.Name }));
    //    }


    //    TfsServices tfs = TfsServices.Connect();
    //    string PN = "ScrumTest3";


    //    public ActionResult GetScrumProjects()
    //    {
    //        var val = tfs.GetScrumProjects().Select(sp => sp.Name).ToList();
    //        return View("Index", val);
    //    }

    //    public ActionResult GetQueries()
    //    {
    //        var val = tfs.GetQueries(PN).Cast<StoredQuery>().Select(sq => sq.Name).ToList();
    //        return View("Index", val);
    //    }

    //    public ActionResult GetProjectContributors()
    //    {
    //        var val = tfs.GetProjectContributors(PN).ToList();
    //        return View("Index", val);
    //    }

    //    public ActionResult GetSprints()
    //    {
    //        var val = tfs.GetSprints(PN).Select(s => s.Title).ToList();
    //        return View("Index", val);
    //    }

    //    public ActionResult GetTeamSprints()
    //    {
    //        var val = tfs
    //            .GetSprints(PN)
    //            .SelectMany(s => tfs.GetTeamSprints(PN, s.Id).Select(ts => s.Title + ": " + ts.Title)).ToList();
    //        return View("Index", val);
    //    }

    //    public ActionResult GetProductBacklogs()
    //    {
    //        var val = tfs.GetSprints(PN).SelectMany(s => tfs.GetProductBacklogs(PN, s.IterationPath).Select(pbl => s.Title + ": " + pbl.Title)).ToList();
    //        return View("Index", val);
    //    }
    //}
}
